<?php
$loader->requireOnce('includes/RadConnector/RadComponentConnector.class.php');
class RadAssignmentConnector extends RadComponentConnector {
	private $logger;
    const PATH_RAD_PROCESSOR_FACTORY    =   'RadProcessor/RadProcessorFactory';
    const PATH_CONTROLLER_RADIOLOGY     =   'C_Radiology';
	public function __construct() {
		parent::__construct();
		$this->logger =  LoggerManager::getLogger('includes.RadConnector.RadAssignmentConnector');
	}

	public function loadAssignmentInputDetails($enumRadType, $ticketId, $triggeredElement){
		$this->logger->info("Start function loadAssignmentInputDetails {enumRadType=$enumRadType, ticketId=$ticketId, triggeredElement=$triggeredElement}");
		$objFactory   =   $this->hisLoader->getObj(self::PATH_RAD_PROCESSOR_FACTORY);
        $objProcessor =   $objFactory->createProcessor($enumRadType);
        $this->logger->info("Finish function loadAssignmentInputDetails {enumRadType=$enumRadType, ticketId=$ticketId, triggeredElement=$triggeredElement}");
        return $objProcessor->loadAssignmentInputDetails($ticketId, $triggeredElement);
	}

	public function saveAssignmentTicket($data) {
        $enumRadType    =   $data['radType'];
        $objFactory     =   $this->hisLoader->getObj(self::PATH_RAD_PROCESSOR_FACTORY);
        $objProcessor   =   $objFactory->createProcessor($enumRadType);
        return $objProcessor->saveAssignmentTicket($data);
	}

	public function loadRadiologyAssignmentList($ticketId, $triggeredElement) {
        $conntroller    =    $this->hisLoader->getObj(self::PATH_CONTROLLER_RADIOLOGY);
		return $conntroller->actionListAssignmentTicketAjax($ticketId, $triggeredElement);
	}

	public function deleteAssignmentTicket($radTicketId, $itemType) {
		$this->logger->info("Start function deleteAssignmentTicket {radTicketId=$radTicketId, itemType='$itemType'}");
		$conntroller    =    $this->hisLoader->getObj(self::PATH_CONTROLLER_RADIOLOGY);
        $this->logger->info("Finish function deleteAssignmentTicket {radTicketId=$radTicketId, itemType='$itemType'}");
        return json_decode($conntroller->actionDeleteAssignmentTicketAjax($radTicketId, $itemType), true);
	}

	public function loadAssignmentEdit($enumRadType, $radTicketId, $triggeredElement){
        $this->logger->info("Start function loadAssignmentEdit {enumRadType=$enumRadType, radTicketId=$radTicketId, triggeredElement=$triggeredElement}");
        $objFactory   =   $this->hisLoader->getObj(self::PATH_RAD_PROCESSOR_FACTORY);
        $objProcessor =   $objFactory->createProcessor($enumRadType);
        $this->logger->info("Finish function loadAssignmentEdit {enumRadType=$enumRadType, radTicketId=$radTicketId, triggeredElement=$triggeredElement}");
        return $objProcessor->loadAssignmentEdit($radTicketId, $triggeredElement);
	}
}
?>